package com.ceair.enums;

import lombok.Getter;

/**
 * @author wangbaohai
 * @ClassName DeleteStatus
 * @description: 删除状态枚举类
 * @date 2025年03月01日
 * @version: 1.0.0
 */
@Getter
public enum DeleteStatus {

    /**
     * 未删除状态：code 为 false
     */
    NOT_DELETED(false, "未删除"),

    /**
     * 已删除状态：code 为 true
     */
    DELETED(true, "已删除");

    private final Boolean code;
    private final String description;

    DeleteStatus(Boolean code, String description) {
        this.code = code;
        this.description = description;
    }

    /**
     * 根据 Boolean 类型的 code 获取对应的枚举实例
     *
     * @param code 状态 code
     * @return 对应的 DeleteStatus 枚举值，如果不存在则返回 null
     */
    public static DeleteStatus getByCode(Boolean code) {
        if (code != null) {
            for (DeleteStatus status : DeleteStatus.values()) {
                if (status.getCode().equals(code)) {
                    return status;
                }
            }
        }
        return null;
    }

}
